package com.imesne.office.excel.read;

import com.imesne.office.excel.model.ExcelBook;
import com.imesne.office.excel.model.ExcelCell;
import com.imesne.office.excel.model.ExcelRow;
import com.imesne.office.excel.model.ExcelSheet;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

/**
 * Excel读取扩展处理接口
 * <p>
 * Created by liyd on 17/7/12.
 */
public interface ExcelReadProcessor {

    /**
     * 处理ExcelBook
     *
     * @param excelBook  the excel book
     * @param workbook   the workbook
     * @param excelBytes the excel bytes
     */
    void processExcelBook(ExcelBook excelBook, Workbook workbook, byte[] excelBytes);

    /**
     * 处理ExcelSheet
     * <pre>
     *  返回值：
     *  -1 停止读取返回数据不包含当前sheet
     *  0 停止读取返回数据包含当前sheet
     *  1 继续读取
     * </pre>
     *
     * @param excelSheet the excel sheet
     * @param sheet      the sheet
     * @param workbook   the workbook
     * @param sheetIndex the sheet index
     * @return int
     */
    int processExcelSheet(ExcelSheet excelSheet, Sheet sheet, Workbook workbook, int sheetIndex);


    /**
     * 处理ExcelRow
     * <pre>
     *  返回值：
     *  -1 停止读取返回数据不包含当前row
     *  0 停止读取返回数据包含当前row
     *  1 继续读取
     * </pre>
     *
     * @param excelRow   the excel row
     * @param row        the row
     * @param workbook   the workbook
     * @param sheet      the sheet
     * @param sheetIndex the sheet index
     * @param rowIndex   the row index
     * @return the int
     */
    int processExcelRow(ExcelRow excelRow, Row row, Workbook workbook, Sheet sheet, int sheetIndex, int rowIndex);

    /**
     * 处理ExcelCell
     * <pre>
     *  返回值：
     *  -1 停止读取返回数据不包含当前cell
     *  0 停止读取返回数据包含当前cell
     *  1 继续读取
     * </pre>
     *
     * @param excelCell  the excel cell
     * @param workbook   the workbook
     * @param sheet      the sheet
     * @param sheetIndex the sheet index
     * @param row        the row
     * @param rowIndex   the row index
     * @param cell       the cell
     * @param cellIndex  the cell index
     * @return the int
     */
    int processExcelCell(ExcelCell excelCell, Workbook workbook, Sheet sheet, int sheetIndex, Row row, int rowIndex, Cell cell, int cellIndex);
}
